package help;

import java.util.List;

public class PageBean<T> {
	private int pageNum;//当前页 ,从第一页开始
	private int pagesize;  //每页的数据项
	private int totalRecord;//总的记录条数
	private int totalPage;//总的记录条数
	private int startIndex;//开始记录数
	private int start;//开始页数
	private int end;//结束页数
	private int step; //中间的跨度  前一页，本页，下一页 则跨度为2,为偶数
	private List<T> list;
	public PageBean(int pageNum,int pagesize,int totalRecord,int step) {
		// TODO Auto-generated constructor stub
		this.pageNum = pageNum;
		this.pagesize = pagesize;
		this.totalRecord = totalRecord;
		if(totalRecord%pagesize==0){
			this.totalPage = totalRecord/pagesize;
		}
		else{
			this.totalPage = totalRecord/pagesize+1;
		}
		this.startIndex = (pageNum-1)*pagesize;
		this.start = 1;
		this.end = start+step;
		if(totalPage<step+1){
			System.out.println("这里执行了没有");
			this.end = this.totalPage;
		}else{
			this.start = pageNum-step/2;
			this.end = pageNum+step/2;
			System.out.println("这里执行了没有2"+pageNum);
			System.out.println("这里执行了没有2"+end);
			if(start<=0){
				this.start = 1;
				this.end =start+step-1;
				//System.out.println("这里执行了没有3"+end);
				
			}
			if(end>this.totalPage){
				end=this.totalPage;
				//this.start = end-step;
				System.out.println("这里执行了没有4"+end);
			}
			
		}
		
	}
	/**
	 * @return the pageNum
	 */
	public int getPageNum() {
		return pageNum;
	}
	/**
	 * @param pageNum the pageNum to set
	 */
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	/**
	 * @return the pagesize
	 */
	public int getPagesize() {
		return pagesize;
	}
	/**
	 * @param pagesize the pagesize to set
	 */
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	/**
	 * @return the totalRecord
	 */
	public int getTotalRecord() {
		return totalRecord;
	}
	/**
	 * @param totalRecord the totalRecord to set
	 */
	public void setTotalRecord(int totalRecord) {
		this.totalRecord = totalRecord;
	}
	/**
	 * @return the totalPage
	 */
	public int getTotalPage() {
		return totalPage;
	}
	/**
	 * @param totalPage the totalPage to set
	 */
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	/**
	 * @return the startIndex
	 */
	public int getStartIndex() {
		return startIndex;
	}
	/**
	 * @param startIndex the startIndex to set
	 */
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	/**
	 * @return the start
	 */
	public int getStart() {
		return start;
	}
	/**
	 * @param start the start to set
	 */
	public void setStart(int start) {
		this.start = start;
	}
	/**
	 * @return the end
	 */
	public int getEnd() {
		return end;
	}
	/**
	 * @param end the end to set
	 */
	public void setEnd(int end) {
		this.end = end;
	}
	/**
	 * @return the step
	 */
	public int getStep() {
		return step;
	}
	/**
	 * @param step the step to set
	 */
	public void setStep(int step) {
		this.step = step;
	}
	/**
	 * @return the list
	 */
	public List<T> getList() {
		return list;
	}
	/**
	 * @param list the list to set
	 */
	public void setList(List<T> list) {
		this.list = list;
	}
	

}
